// pages/mine/mine.js
Page({

  
  data: {
    uid:'',loginflag:false,nickName:'',avatarUrl:'',show:false,type:'',id:''
    
    
  },
onLoad(){
  this.getsystem()
   console.log(wx.getStorageSync('uid'));
    this.getshopshare()
},
 
  onShow: function (options) {
    this.gettypestatus()
    this.getshopshare()
    console.log(wx.getStorageSync('uid'));
    let uid=wx.getStorageSync('uid')?wx.getStorageSync('uid'):''
    if(uid==''){
      wx.navigateTo({
        url: '/pages/mine/loginuser/loginuser?id='+this.data.id,
      })
    }
    let avatarUrl=wx.getStorageSync('avatarUrl')?wx.getStorageSync('avatarUrl'):''
    let nickName=wx.getStorageSync('nickName')?wx.getStorageSync('nickName'):''
    let loginflag=wx.getStorageSync('loginflag')==true?wx.getStorageSync('loginflag'):'flase'
    this.setData({
      uid,
      avatarUrl,
      nickName,
      loginflag
    })
    if(uid){this.setData({loginflag:true})}else{this.setData({loginflag:false})}
  
  },
  loginclick(){
    wx.navigateTo({
      url: '../mine/loginuser/loginuser',
    })
  },
 
   
  //退出登录
  loginout(){
    wx.clearStorageSync("uid")
    this.setData({
      loginflag:false
    })
  },
  //联系客服回调函数
  handleContact(e){
    console.log(e);
    

  },
  //我要反馈 路由跳转
    feedback(){
      
      
        wx.navigateTo({
          url: '/pages/mine/feedbak/add/add',
        })
    },
    //反馈
    navfankui(){
         wx.navigateTo({
           url: '/pages/mine/fankui',
         })
    },
    //跳转到余额页面
    priceclick(){
     wx.navigateTo({
       url: '/pages/mine/mine_price/mine_priceall',
     })
     
    },
     //跳转到优惠卷页面
     lowestclick(){
         wx.navigateTo({
           url: '/pages/mine/mine_price/mine_price',
         })
     },
   
 
   
  onPullDownRefresh: function () {
    var taht = this;
    this.onLoad();
    
  },
    //跳转到实名认证
    authenclick(){
        wx.navigateTo({
          url: '/pages/mine/authen/authen',
        })

    },
    navconcat(){
      wx.navigateTo({
        url: '/pages/mine/concat/concat',
      })
    },
  
  // 我的余额
  price:function(){
    wx.navigateTo({
         url: '../mine/price',
    })
  },

  //我的地址
  address:function(){
    wx.navigateTo({
      url: '/pages/mine/address/address',
    })
  },
  //我的订单
    order:function(e){
        var order = e.currentTarget.dataset.order;
        wx.navigateTo({
          url:"/pages/orderprint/orderprint?change="+order
        })
      },
    //跳转到我的优惠券
    navnewcoupon(e){
      wx.navigateTo({
        url: '/pages/mine/newcoupon?statu='+e.currentTarget.dataset.statu,
      })
    },
    //跳转到我的设置
    navset(){
      
      console.log(11);
      
      wx.navigateTo({
        url: '../mine/set/set'
      })
    },
    navcanvas(){
        wx.navigateTo({
          url: '/pages/cropper/canvas',
        })
    },
    navhoutai(e){
        wx.navigateTo({
          url: './store_admin/index?type='+e.currentTarget.dataset.type,
        })
    },
     //获取用户是否是店家还是共享商  在uid有的情况下 获取
     getshopshare(){
      wx.request({
        url: 'https://zujieba.com/Api/member/member.html',
        data:{uid:wx.getStorageSync('uid')},
        method:'POST',
        success:(res)=>{
          console.log(res);
          let type=res.data.data.type
          this.setData({
            type
          })
          
        }
      })

   },
   //绑定下级
   navbangding(){
      wx.navigateTo({
        url: '/pages/mine/store_admin/xiaji',
      })
   },
   //跳转到回收设备
   navhuishou(){
     wx.navigateTo({
       url: '/pages/mine/huishougoods',
     })
   },
   //通过uid改变type
    gettypestatus(){
      let uid=wx.getStorageSync('uid')
      if(!uid){
        console.log(11);
        
             this.setData({
               type:''
             })
      }
    },
    onShareAppMessage(){
      let pid=wx.getStorageSync('uid')
      return{title:'慧享印',path:'/pages/index/index?pid='+pid,imageUrl:'../../img/mingpian.jpg'}
       
    },
    getsystem(){
      wx.getSystemInfo({
        complete: (res) => {
          console.log(res);
          let menubutton= wx.getMenuButtonBoundingClientRect() 
          console.log(menubutton.height);
         let barheight = res.statusBarHeight +menubutton.height + (menubutton.top-res.statusBarHeight )*2
         console.log(barheight);
          this.setData({
            barheight,
            inheight:barheight-(barheight-menubutton.top-menubutton.height)
          })
        },
      })
   }

})